package com.example.shanyi.zyfypt_204sy.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.example.shanyi.zyfypt_204sy.R;
import com.example.shanyi.zyfypt_204sy.iface.RegisterListener;
import com.example.shanyi.zyfypt_204sy.model.RegisterModel;



public class RegisterActivity extends AppCompatActivity implements View.OnClickListener{
private TextView tv1,tvname,tvi,tvl,tvage,tvpw,tvname1,tvpw2,tvph;
    private Button b0,bp,bb;
    private EditText et1,et2,et3,et4,et9;
    RegisterListener registerListener = new RegisterListener() {
        @Override
        public void onResponse(String msg) {
            if(msg.equals("1")){
                System.out.println("result:"+msg);
                finish();
            }else{
                System.out.println("result:"+msg);
            }
        }

        @Override
        public void onFail(String msg) {
            Toast.makeText(RegisterActivity.this, msg, Toast.LENGTH_SHORT).show();
        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        init();
    }
    private void init(){
        et1=(EditText)findViewById(R.id.register_name);
        et2=(EditText)findViewById(R.id.register_pwd);
        et3=(EditText)findViewById(R.id.register_pwd2);
        et4=(EditText)findViewById(R.id.register_age);
        et9=(EditText)findViewById(R.id.register_relname);

        bb=(Button)findViewById(R.id.register_submit);
        bb.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.register_submit:
                finish();
                break;
        }

        System.out.println("注册——提交");
        RegisterModel registerModel = new RegisterModel();
        registerModel.getResult(et1.getText().toString(),
                et2.getText().toString(),
                et3.getText().toString(), registerListener);
    }
    }

